"""
认证配置模块
用于JWT认证相关配置
"""
from datetime import timedelta
from pydantic_settings import BaseSettings
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()


class AuthSettings(BaseSettings):
    """认证配置类"""
    # JWT配置
    SECRET_KEY: str = "your-secret-key-here-change-in-production"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    REFRESH_TOKEN_EXPIRE_DAYS: int = 7
    
    # 密码哈希配置
    BCRYPT_ROUNDS: int = 12
    
    class Config:
        env_file = ".env"
        extra = 'allow'


# 创建认证配置实例
settings = AuthSettings()

# 访问令牌过期时间
ACCESS_TOKEN_EXPIRE_TIME = timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)

# 刷新令牌过期时间
REFRESH_TOKEN_EXPIRE_TIME = timedelta(days=settings.REFRESH_TOKEN_EXPIRE_DAYS)